'''
继承
共用相同方法 属性
'''

class Person(object):
    '''人'''

    def __init__(self, name, age):
        self._name = name
        self._age = age

    @property
    def name(self):
        return self._name
    
    @property
    def age(self):
        return self._age

    @age.setter
    def age(self, age):
        self._age = age

    def play(self):
        print('%s正在愉快的玩耍.' % self._name)

    def watch_movie(self):
        if self._age >= 18:
            print('%s正在观看爱情动作片.' % self._name)
        else:
            print('%s只能观看《熊出没》.' % self._name)

class Student(Person):
    '''学生'''

    def __init__(self, name, age, grade):
        super(Student, self).__init__(name, age)
        self._grade = grade

    @property
    def grade(self):
        return self._grade

    @grade.setter
    def grade(self, grade):
        self._grade = grade

    def study(self, course):
        print('%s的%s正在学习%s.' % (self._grade, self._name, course))

class Teacher(Person):
    '''老师'''
    def __init__(self, name, age, title):
        super(Teacher, self).__init__(name, age)
        self._title = title

    @property
    def title(self):
        return self._title
    
    @title.setter
    def title(self, title):
        self._title = title

    def teach(self, course):
        print('%s的%s正在教授%s.' % (self._title, self._name, course))

def main():
    student = Student('小明', 16, '高中')
    student.study('数学')
    student.watch_movie()        
    teacher = Teacher('小红', 22, '叫兽')
    teacher.teach('java入门到精通')
    teacher.watch_movie()

if __name__ == '__main__':
    main()